#include <iostream>
#include <utility>
using namespace std;

int main()
{
    int a, b ,c;
    int q;
    cin >> q;
    while (q--)
    {
        cin >> a >> b >> c;
        int x = std::min(a, min(b, c));
        cout << (x + std::max(b - x -1, 0)) << endl;
    }
    return 0;
}